|
|
|
|
|
|
|
Dim inCounter As Integer
For Each anyNode In tv1.Nodes
If anyNode.Children <> 0 Then 'this node is a parent
Print anyNode.Text & "'s children are: "
Set kidNode = anyNode.child
Print kidNode.Text
inCounter = kidNode.FirstSibling.Index
While inCounter <> kidNode.LastSibling.Index
Print tv1.Nodes(inCounter).Next.Text
inCounter = tv1.Nodes(inCounter).Next.Index
Wend
End If
Next anyNode
End Sub |
|
|
|
|
|
|
|
|
Remember, a given node has only one Child. All the other nodes that share the Child's parent are considered "Next" or "Previous" nodes. However, among all the nodes that share the same value for the Parent property, you can find a FirstSibling and a LastSibling. |
|
|
|
|
|
|
|
|
|
Nodes are tricky; there's no question about it. One of the best ways to get a grasp of the concept of nodes is to see the node code (no poetry intended) in action. The online help file examples that Microsoft provides with your version of VB are pretty good once you have a basic understanding of the hierarchy concepts. I suggest that you create several test programs until you are comfortable using the TreeView control.  |
|
|
|
|
|
|
|
|
|
|
To learn more about the TreeView control, keep reading. This section focused on accessing nodes already in the TreeView control. In the next section, you will add nodes to a TreeView control as part of a sample project. |
|
|
|
|
|
|
|
|
Using the TabStrip Control |
|
|
|
|
|
|
|
|
The TabStrip, shown in Figure 12.12, is a control widely used in the Windows interface arsenal. It allows you to divide a form visually into several tabs, creating the appearance of a set of organized folders. |
|
|
|
|
|
|
|
|
The TabStrip shown in the figure is the sample project you'll create in this section. In this sample project, the purpose of the TabStrip control is to switch between two lists of information; the lists are baseball teams displayed in a TreeView control. The TabStrip enables you to select which league to display. |
|
|
|
|
|
|
|
|
Starting the Sample Project |
|
|
|
|
|
|
|
|
To begin the TreeTab project, start a new Standard EXE project in Visual Basic. Then follow these steps: |
|
|
|
|
|
|
|
|
1. Add a TabStrip control, and name it something short and meaningful, like tsMain. |
|
|
|
|
|
|
|
|
2. Add a TreeView control to the form, and name it tv1. Now you are ready to start setting the properties of the controls. |
|
|
|
|
|